package com.project.estate.building.controller;

import com.project.estate.building.service.BuildingService;
import com.project.estate.commons.bean.Building;
import com.project.estate.commons.config.JsonResult;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/building")
public class BuildingController {

    @Resource
    private BuildingService buildingService;

    @PostMapping("/add_building")
    public JsonResult addBuilding(Building building) {
        return buildingService.addBuilding(building);
    }

    //修改
    @PutMapping("/update_building/{comId}")
    public JsonResult updateBuilding(Building building, @PathVariable("comId") String comId) {
        return buildingService.updateBuilding(comId, building);
    }

    //查询
    @GetMapping("/find_building/{comId}")
    public JsonResult findAllBuildings(@PathVariable("comId") String comId) {
        return buildingService.findBuilding(comId);
    }

    //删除
    @DeleteMapping("/delete_building/{comId}")
    public JsonResult deleteBuilding(@PathVariable("comId") String comId) {
        return buildingService.deleteBuilding(comId);
    }
}
